package com.example.service.impl;

import com.example.mapper.DeptMapper;
import com.example.pojo.Dept;
import com.example.service.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.List;
@Slf4j
@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    public DeptMapper deptMapper;
    @Override
    public List<Dept> list() {
        log.info("调用deptmapper");
        return deptMapper.list();
    }

    @Override
    public void delect(Integer id) {
        deptMapper.delect(id);
    }

    @Transactional
    @Override
    public void insert(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        dept.setCreateTime(LocalDateTime.now());
        deptMapper.insert(dept);
    }

    @Override
    public void updata(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.updata(dept);

    }
}
